package com.dt.dubai.core.aliyun.aliyunOss.controller;

import com.dt.dubai.core.aliyun.aliyunOss.service.ser.AliyunOssService;
import com.dt.dubai.core.comm.PageData;
import com.dt.dubai.core.exception.PageErrorMesg;
import com.dt.dubai.core.utile.I18nUtile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/aliyun/aliyunOss")
public class AliyunOssController {

    @Autowired
    protected AliyunOssService aliyunOssService;

    @Autowired
    protected I18nUtile i18nUtile;

    @RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
    @ResponseBody
    public PageData<String> uploadFile() {
        aliyunOssService.uploadFile();
        return new PageData().success("SUCESS", i18nUtile.getMessage(PageErrorMesg.E0.name()));
    }

    @RequestMapping(value = "/multipartUpload", method = RequestMethod.POST)
    @ResponseBody
    public PageData<String> multipartUpload() {
        aliyunOssService.multipartUpload();
        return new PageData().success("SUCESS", i18nUtile.getMessage(PageErrorMesg.E0.name()));
    }

    @RequestMapping(value = "/breakpointUpload", method = RequestMethod.POST)
    @ResponseBody
    public PageData<String> breakpointUpload() {
        aliyunOssService.breakpointUpload();
        return new PageData().success("SUCESS", i18nUtile.getMessage(PageErrorMesg.E0.name()));
    }

    @RequestMapping(value = "/callBack", method = RequestMethod.POST)
    @ResponseBody
    public PageData<String> callBack() {
        aliyunOssService.callBack();
        return new PageData().success("SUCESS", i18nUtile.getMessage(PageErrorMesg.E0.name()));
    }

}
